function throttle(fn: () => void, wait: number) {
    let flag = true, timer: ReturnType<typeof setTimeout> | null = null
    return function(this: any, ...args: []) {
        if(flag) {
            flag = false
            timer = setTimeout(() => {
                fn.apply(this, args)
                flag = true
            }, wait)
        }
    }
}

function listener() {
    console.log('监听事件发生')
}

let scroll = throttle(listener, 500)



let n = 1
let ot = setInterval(() => {
    n++
    if(n >= 100) clearInterval(ot)
    if(n < 100) {
        scroll()
    } 
}, 60)

export {}